var options = {
		series : [ {
		name : '货物类型',
		type : 'pie',
		radius : '55%',
		data : [ {} ]
	} ]
 };


var hwlxChart = echarts.init(document.getElementById('hwlxdiv'));
hwlxChart.setOption(options);

var viurl = "/statistics/hwlxStatistics.action";
load(viurl, hwlxChart);

/***加载数据***/
function load(url, myChart){
	//myChart.showLoading();
	$('#totalnum').html(0);
    $.get(mainDomain + url).done(function (data) {
    	var categories = data.categories;  
        var values = data.countList;  
//        $('#totalnum').html(data.listSize);
        // 填入数据
        myChart.setOption({
        	title : {  
                text: '货物类型',  
                subtext: '饼图',  
                x:'left',  
                backgroundColor:'rgba(12,121,123,0.1)'  
              },
	          tooltip : {  
	              trigger: 'item',  
	              formatter: "{a} <br/>{b} : {c} ({d}%)"  
	            },
	            legend: {  
                    orient : 'vertical',  
                    x : 'right',  
                    data:categories,  
                  },
            series : [
                {
                    name: '货物类型',
                    type: 'pie',
                    radius: '85%',
                    center: ['50%', '50%'],
                    data: (function(){  
                        var res = [];  
                        var len = values.length;  
                        while (len--) {  
                            res.push({  
                            name: categories[len],  
                            value: values[len]  
                        });  
                        }  
                        return res;  
                        })()
                }
            ]
        })
    });
}

/*function doSearch(){
	var fromdate = $('#fromdate').datebox('getValue');
	var todate = $('#todate').datebox('getValue');
	searchurl = viurl;
	if(fromdate!=null&&fromdate!=''&&todate!=null&&todate!=''){
		searchurl += '?fromdate=' + fromdate+'&todate='+todate;
		load(searchurl, yhxxChart);
		return;
	}
	if(fromdate!=null&&fromdate!=''){
		searchurl += '?fromdate=' + fromdate;
		load(searchurl, yhxxChart);
		return;
	}
	if(todate!=null&&todate!=''){
		searchurl += '?todate=' + todate;
		load(searchurl, yhxxChart);
		return;
	}
	if(fromdate==''&&todate==''){
		load(viurl, yhxxChart);
		return;
	}
}*/